/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.business.customer.core.repository.mapper;

import info.peigen.hotpot.business.customer.core.repository.entity.CustomerLogEntity;
import info.peigen.hotpot.business.customer.facade.enums.CustomerLogType;
import info.peigen.hotpot.component.data.repository.beetlsql.mapper.AbstractBeetlSqlMapper;
import org.apache.ibatis.annotations.Mapper;
import org.beetl.sql.mapper.annotation.Select;
import org.beetl.sql.mapper.annotation.Sql;
import org.beetl.sql.mapper.annotation.Update;

import java.util.List;

/**
 * <b>(CustomerLogMapper)</b>
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2021/11/3
 */

@SuppressWarnings("AlibabaAbstractMethodOrInterfaceMethodMustUseJavadoc")
@Mapper
public interface CustomerLogMapper extends AbstractBeetlSqlMapper<CustomerLogEntity> {
    @Sql("select * from customer_log where customer_id = ? order by create_time desc ")
    @Select
    List<CustomerLogEntity> listByCustomerId(String customerId);

    @Sql("select * from  customer_log where customer_id = ? and type = ? ORDER BY create_time DESC LIMIT 1")
    @Select
    CustomerLogEntity findByCustomerIdAndTypeLast(String customerId, CustomerLogType type);

    @Sql("delete from customer_log where customer_id = ? and type = ?")
    @Update
    void deleteByCustomerId(String customerId, CustomerLogType type);
}